package com.gis.visualization.controller.fileoss;

import com.gis.visualization.config.result.R;
import com.gis.visualization.service.VideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
@RequestMapping("/gis/video")
@CrossOrigin
@Api("视频管理")
public class VideoController {
    @Autowired
    private VideoService videoService;

    //    上传视频到阿里云
    @ApiOperation("上传视频到阿里云")
    @PostMapping("uploadVideo")
    public R uploadVideo(MultipartFile file) {
        String videoId = videoService.uploadVideo(file);
        return R.ok().data("videoId", videoId).message(file.getOriginalFilename() + "上传成功");
    }

    @ApiOperation("删除上传到阿里云的视频")
    @DeleteMapping("removeVideo/{videoId}")
    public R removeALYVideo(@PathVariable String videoId) {
        videoService.removeALYVideo(videoId);
        return R.ok().message("删除视频成功");
    }

    @ApiOperation("根据人物id获取视频播放的凭证")
    @GetMapping("getPlayAuth/{figureId}")
    public R getPlayAuth(@PathVariable String figureId) {
        Map<String, String> video = videoService.getPlayAuth(figureId);
        return R.ok().data("video", video);
    }

    // @ApiOperation("根据人物id获取视频id")
    // @GetMapping("getVideoId/{figureId}")
    // public R getVideoId(@PathVariable String figureId) {
    //     String playAuth = videoService.getVideoId(figureId);
    //     return R.ok().data("playAuth", playAuth);
    // }
}
